﻿using HLStock.Common;
using HLStock.Model;
using HLStock.WmsService;

namespace HLStock.DBAccess.AOP
{
    public class StockOutRecordRewrite 
        : IAfterSaveAction<StockRecordModel>,
        IAfterDeleteAction<StockRecordModel>
    {
        public void Handle(AfterSaveOrDeleteEventArgs<StockRecordModel> arg)
        {
            if (arg.Data.Type == StockType.In) return;
            var sp = ServiceLoader.GetService<StockRecordServiceProvider>();
            var m = sp.Get(arg.Data.SrcRecord);
            sp.UpdateOnHand(m);
        }
    }
}
